#include <jni.h>
#include <string>

//extern "C" JNIEXPORT jstring JNICALL
//Java_com_qsw_bsdifflib_NativeLib_stringFromJNI(
//        JNIEnv *env,
//        jobject /* this */) {
//    std::string hello = "Hello from C++";
//    return env->NewStringUTF(hello.c_str());

# include"bspatch.h"

extern "C"
JNIEXPORT void JNICALL

Java_com_qsw_fileoperatelib_bsdiff_PatchUtil_patch(JNIEnv *env,
                                          jclass clazz,
                                          jstring old_file,
                                          jstring new_file,
                                          jstring patch_file) {

    int argc = 4;
    char *argv[argc];

    argv[0] = "bspatch";
    argv[1] = (char *) (env->GetStringUTFChars(old_file, 0));
    argv[2] = (char *) (env->GetStringUTFChars(new_file, 0));
    argv[3] = (char *) (env->GetStringUTFChars(patch_file, 0));

    //调用合并的方法

    main(argc, argv);

    env->ReleaseStringUTFChars(old_file, argv[1]);
    env->ReleaseStringUTFChars(new_file, argv[2]);
    env->ReleaseStringUTFChars(patch_file, argv[3]);
}